<template>
  <div>
    <ContentDetailWrap :title="t('exampleDemo.detail')">
      <template #header>
        <BaseButton @click="router.go(-1)"> 返回 </BaseButton>
      </template>

      <DetailTemplate :current-row="currentRow" />
    </ContentDetailWrap>
  </div>
</template>
<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router'
import { ref } from 'vue'
import DetailTemplate from './DetailTemplate.vue'
import type { EmployeeData } from '@/api/table/types'
import { getEmployees } from '@/api/table'
import { ContentDetailWrap } from '@/components/ContentDetailWrap'
import { useI18n } from '@/hooks/web/useI18n'

const route = useRoute()
const router = useRouter()

const { t } = useI18n()

const empId = ref(route.params.id)

const currentRow = ref<Nullable<EmployeeData>>(null)

const getTableDet = async () => {
  const res = await getEmployees({ empId: empId.value })
  const list = res?.data?.records
  if (list && list.length > 0) {
    currentRow.value = list[0]
  }
}

getTableDet()
</script>
